﻿using AutoMapper;
using Common.Communal;
using MediatR;
using Sell.Api.Write.Application.Command.GoodCommand;
using Sell.Services.Goods;

namespace Sell.Api.Write.Application.CommandHandlers.GoodCommandHandlers
{
    public class GoodDelCommandHandlers : IRequestHandler<GoodDelCommand, Common.Communal.ApiResult<int>>
    {
        public IMapper Mapper { get; }
        public IGoodsServices Services { get; }
        public GoodDelCommandHandlers(IGoodsServices _Services, IMapper _Mapper)
        {
            Mapper = _Mapper;
            Services = _Services;
        }
        /// <summary>
        /// 删除货品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<int>> Handle(GoodDelCommand request, CancellationToken cancellationToken)
        {
            return await Services.DeleteGood(request.Id);
        }
    }
}
